#ifndef AST_EXPRESSION_UNARY_EXPR_H
#define AST_EXPRESSION_UNARY_EXPR_H

#include "../ASTNode.h"

class PostfixExpr;
class UnaryOperator;
class CastExpr;
class sym;


/*
C99 6.5.3
unary-expression:
		postfix-expression
		++  unary-expression
		--  unary-expression
		unary-operator  cast-expression
		sizeof    unary-expression
		sizeof    (    type-name    )
*/
class UnaryExpr : public ASTNode
{
public:
	enum{
		postfix_expr,
		plus_unary_expr,
		sub_unary_expr,
		op_cast_expr,
		sizeof_expr,
		sizeof_type,
	};
protected:
	UnaryExpr() 
		: ASTNode(ASTNode::unary_expression){};
public:
	UnaryExpr(PostfixExpr *pPostExpr)
		: ASTNode(ASTNode::unary_expression)
		, m_iType(postfix_expression)
		, m_pPostfixExpr(pPostExpr){};
	UnaryExpr(UnaryExpr *pUnaryExpr, int iType)
		: ASTNode(ASTNode::unary_expression)
		, m_iType(iType)
		, m_pUnaryExpr(pUnaryExpr){};
	UnaryExpr(CastExpr *pCastExpr, UnaryOperator *pOp)
		: ASTNode(ASTNode::unary_expression)
		, m_iType(op_cast_expr)
		, m_pOpCastExpr(pCastExpr)
		, m_pOperator(pOp){};
	UnaryExpr(sym *pTypeName)
		: ASTNode(ASTNode::unary_expression)
		, m_iType(sizeof_type)
		, m_pTypeName(pTypeName){};


	virtual ~UnaryExpr(void);

	virtual void					codeGen();
protected:
	tiny_int					m_iType;
	union{
		PostfixExpr *				m_pPostfixExpr;
		UnaryExpr *					m_pUnaryExpr;
		struct{
			UnaryOperator *			m_pOperator;
			CastExpr *				m_pOpCastExpr;
		};
		sym *						m_pTypeName;
	};
};


#endif

